package com.dx.wx.controller;

import com.dx.wx.service.DxActService;
import com.dx.wx.service.DxUserService;
import com.ejlchina.data.Array;
import com.ejlchina.data.Mapper;
import com.yf.annotation.LoginUserId;
import com.yf.response.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("/api/dx/act")
public class ApiDxActController {

    @Resource
    private DxActService dxActService;

    @GetMapping("/{id}")
    public R save(@LoginUserId Long phone, @PathVariable String id) {
        Map map = dxActService.findById(id);
        return R.ok(map);
    }

    @PostMapping("/apply")
    public R save(@LoginUserId Long phone, @RequestBody Map map) {
        dxActService.addAct(phone, map);
        return R.ok();
    }

    @Resource
    private DxUserService dxUserService;

    @GetMapping("/list")
    public R list(@LoginUserId Long phone, Long startDate, Long endDate,String appId) {
        Array array = dxActService.actList(phone, startDate, endDate);
        Array topList =  dxUserService.findByTop(Long.valueOf(phone),appId);
        return R.ok(array.toString()).putExtra("topList",topList.toString());
    }


}
